﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;//SqlDataAdapter
using BUS;
namespace _042082
{
    public partial class frmRportLoaiPhong : Form
    {
        public frmRportLoaiPhong()
        {
            InitializeComponent();
        }

        private void frmRportLoaiPhong_Load(object sender, EventArgs e)
        {
            CrystalReportLoaiPhong List = new CrystalReportLoaiPhong();
            List.SetDataSource(BUS.LoaiPhongBUS.getListLoaiPhong());
            // 
            string SQL = "Select TenLoaiPhong From LoaiPhong Where MaLoaiPhong='A'";
            //SqlDataAdapter da = new SqlDataAdapter(
            DataProvider d = new DataProvider();
            DataTable dt = new DataTable();
            dt=d.ExecuteQuery(SQL);
            string parameter = dt.Rows[0][0].ToString();
            // Ngay chổ này : 
        /*  +---------+----------+
		    | MaPhong | TenPhong |
		    +---------+----------+
		    | 1       | PhongA   |
		    +---------+----------+
		    | 2       | PhongB   |
		    +---------+----------+
         * Row[0][0]         ---> 1
         * Row[0]["MaPhong"] ---> 1

        */
            List.SetParameterValue("NguoiLap", parameter);
            crystalReportViewerLoaiPhong.ReportSource = List;
            crystalReportViewerLoaiPhong.Refresh();
        }
    }
}